package com.haoma.controller;

import com.haoma.result.Result;
import com.haoma.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Description:
 */
@RestController
@RequestMapping("/admin/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    /**
     * 统计数量
     *
     * @return
     */
    @GetMapping("/count")
    public Result getCount() {
        Map<String, Long> countMap = homeService.getCount();
        return Result.success(countMap);
    }

    /**
     * 获取热度前7的文章
     *
     * @return
     */
    @GetMapping("/hot")
    public Result getHotTop7() {
        Map<String, List<Object>> hotMap = homeService.getHotTop8();
        return Result.success(hotMap);
    }

    /**
     * 获取到近七日的网站访客数据
     *
     * @return
     */
    @GetMapping("/visitor")
    public Result getVisitor() {
        Map<String, List<Object>> hotMap = homeService.getVisitor();
        return Result.success(hotMap);
    }
}
